package com.wkhyapp.lm.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wkhyapp.lm.R;
import com.wkhyapp.lm.http.vo.Fans;
import com.wkhyapp.lm.http.vo.Goods;
import com.wkhyapp.lm.utils.GetTimeAgo;
import com.wkhyapp.lm.utils.ImageLoadUtil;

import java.util.List;

/**
 * Created by fang on 2021/10/9.
 */

public class CollectionAdapter extends BaseQuickAdapter<Goods, BaseViewHolder> {
    public CollectionAdapter.callBack mCallBack;
    public CollectionAdapter(int layoutResId, List<Goods> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper,final  Goods item) {
        ImageView imageView = helper.getView(R.id.goods_iv);
        ImageLoadUtil.setRoundImage_Normal(mContext,item.getImg(),6,imageView);
        helper.setText(R.id.time_tv, GetTimeAgo.getTimeAgo(item.getUpdateTime()));
        helper.setText(R.id.title_tv,item.getDesc());
        helper.getView(R.id.del_but).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.del(item);
            }
        });
        helper.getView(R.id.collect_rl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCallBack.action(item);
            }
        });
    }


    public void  setCallBack(CollectionAdapter.callBack callBack){
        this.mCallBack = callBack;
    }


    public interface  callBack{
        void action(Goods item);
        void del(Goods item);
    }
}
